//package com.li.controller;
//import com.common.util.MyFileUtil;
//import com.common.util.MyJSONUtil;
//import com.li.model.UserFile;
//import com.li.service.UserFileServiceImpl;
//import com.li.service.UserService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.multipart.commons.CommonsMultipartFile;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//
////ajax文件上下传
//@Api(tags = "用户文件管理")
//@RestController
//@RequestMapping("/resource")
//public class ResourceServlet {
//
//    @Autowired
//    private UserFileServiceImpl fileService;
//
//    //使用Ajax上传
//    @ApiOperation("文件上传接口")
//    @PostMapping("/upload")
//    public String upload(@RequestParam("file") CommonsMultipartFile file, HttpServletRequest request) {
//        return fileService.upload(file,request);
//    }
//    @ApiOperation("通过文件id下载文件")
//    @GetMapping("/download/{id}")
//    public String download(HttpServletRequest request, HttpServletResponse response,@PathVariable int id){
//        UserFile userFile = fileService.queryFileById(id);
//        if (MyFileUtil.fileDownload(response,userFile.getFileName(),userFile.getSavePath())){
//            return "请求成功";
//        }
//        return "请求失败";
//    }
//    @ApiOperation("获取当前用户的所有文件")
//    @GetMapping("/getFileContent")
//    public String getFileInfo(HttpServletRequest request){
//        return MyJSONUtil.toJsonString(fileService.queryFileByUserId((int)request.getSession().getAttribute("USER_SESSION")));
//    }
//
//}
